'''
Author: Ryan
Email: 409266255@qq.com
Date: 2025-09-19 17:21:49

LastEditors: Ryan
LastEditTime: 2025-09-30 17:28:24
Description: 配置文件

FilePath: /qopilot/qopilot/config.py
Copyright (c) 2025 by Ryan, All Rights Reserved. 
'''

import os
from pathlib import Path
from typing import Optional


class Config:
    """配置类"""

    # Tushare配置
    TUSHARE_TOKEN: Optional[str] = os.getenv('TUSHARE_TOKEN', 'd59ec2d116980f4e762333eac5783dc57f5278c686531eff43b0ce7b')

    # 数据库配置
    DATABASE_DIR: str = Path('database')
    DATABASE_PATH_HK: str = DATABASE_DIR / 'qopilot_hk.db'
    DATABASE_PATH_US: str = DATABASE_DIR / 'qopilot_us.db'

    @classmethod
    def validate(cls) -> bool:
        """验证配置是否完整"""
        if not cls.TUSHARE_TOKEN:
            raise ValueError("请设置TUSHARE_TOKEN环境变量")
        return True


# 全局配置实例
config = Config()
